package o;

import android.annotation.SuppressLint;
import android.os.Bundle;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.savedstate.SavedStateRegistry$1;
import java.util.Iterator;
import java.util.Map.Entry;

@SuppressLint({"RestrictedApi"})
public final class mr {
    public boolean ˊ = true;
    private dh<String, c> ˋ = new dh();
    @Nullable
    private Bundle ˎ;
    private boolean ˏ;

    public interface c {
        @NonNull
        Bundle ॱ();
    }

    public interface e {
        void ˎ(@NonNull my myVar);
    }

    mr() {
    }

    @MainThread
    @Nullable
    public Bundle ˋ(@NonNull String str) {
        if (!this.ˏ) {
            throw new IllegalStateException("You can consumeRestoredStateForKey only after super.onCreate of corresponding component");
        } else if (this.ˎ == null) {
            return null;
        } else {
            Bundle bundle = this.ˎ.getBundle(str);
            this.ˎ.remove(str);
            if (!this.ˎ.isEmpty()) {
                return bundle;
            }
            this.ˎ = null;
            return bundle;
        }
    }

    @MainThread
    void ॱ(@NonNull kp kpVar, @Nullable Bundle bundle) {
        if (this.ˏ) {
            throw new IllegalStateException("SavedStateRegistry was already restored.");
        }
        if (bundle != null) {
            this.ˎ = bundle.getBundle("androidx.lifecycle.BundlableSavedStateRegistry.key");
        }
        kpVar.ॱ(new SavedStateRegistry$1(this));
        this.ˏ = true;
    }

    @MainThread
    void ˎ(@NonNull Bundle bundle) {
        Bundle bundle2 = new Bundle();
        if (this.ˎ != null) {
            bundle2.putAll(this.ˎ);
        }
        Iterator ˊ = this.ˋ.ˊ();
        while (ˊ.hasNext()) {
            Entry entry = (Entry) ˊ.next();
            bundle2.putBundle((String) entry.getKey(), ((c) entry.getValue()).ॱ());
        }
        bundle.putBundle("androidx.lifecycle.BundlableSavedStateRegistry.key", bundle2);
    }
}
